< previous page page_405 next page >

Page 405
Examples Filename: FileRead.frm
In the form shown in Figure 20.4, youll select a file to read using the file controls.
8160-0405a.gif
Figure 20.4
Reading information from a file.
Once the file is highlighted in the Select File to Read list box, you click the Read command button. In the Click event of the Read button is where youll open the file and read in each line until you hit the end of the file:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdRead_Click()
   Dim oFile As TextStream
   Dim strValue As String
   Dim strFileName As String

   Screen.MousePointer = vbHourglass

   strFileName = GetFileName()

   Set oFile = New TextStream
   With oFile
      .FileName = strFileName
      ' Check For File Too Big - 32K limit on text boxes
      If .FileTooBig Then
         Beep
         Screen.MousePointer = vbDefault
         MsgBox "File Too Big To Read", , "File Open Error"
      Else

 
< previous page page_405 next page >

If you like this book, buy it!